home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: June, 2000
- //
-
- global proc int
- bsMultiIndexForTarget(string $bsn, int $wc)
- //
- // Description:
- // Return the multiIndex that corresponds to target $wc on $bsn.
- //
- {
- string $sArr[] = `ls -sl`;
- if (nodeType($bsn) != "blendShape") {
- // find the blendShape node:
- // $bsn may be either the blendShape node, or the transform
- // above the base shape of the blendShape
- //
- string $isType[] = `ls -type transform $bsn`;
- if (size($isType)) {
- string $children[] = `pickWalk -d down $bsn`;
- if (size($children)) {
- $bsn = $children[0];
- }
- select -r $sArr;
- }
- $isType = `listConnections -type blendShape $bsn`;
- if (size($isType)) {
- $bsn = $isType[0];
- } else {
- error("Must specify a blendShape node.");
- return -1;
- }
- }
-
- // if final target index is being requested, search for the max target
- //
- int $maxTarget = 0;
- int $searchForMax = (`blendShape -q -wc $bsn` == ($wc+1));
-
- string $allTargets[] = `listAttr -m ($bsn+".inputTarget")`;
- string $targets[];
- for ($t in $allTargets) {
- // weed out the in-between targets
- //
- if ("" != `match "6000" $t` && "" != `match "inputPointsTarget" $t` ) {
- $targets[size($targets)] = $t;
-
- if ($searchForMax) {
- int $tmp = bsTargetIndex($t);
- if ($tmp > $maxTarget) {
- $maxTarget = $tmp;
- }
- }
- }
- }
- if (size($targets) <= $wc) {
- return -1;
- }
-
- int $targetIndex;
- if ($searchForMax) {
- $targetIndex = $maxTarget;
- } else {
- string $targetPlug = $targets[$wc];
- $targetIndex = bsTargetIndex($targetPlug);
- }
- return $targetIndex;
- }
-
-